/**
 * @description Model Manifest
 *
 * @author Xiongmao
 */

var db = require('../db');

const Ticket = db.model('Ticket', {
    tableName: 'tickets',
    hasTimestamps: true,

    parent() {
        return this.belongsTo('Type', 'parent_id');
    },

    types() {
        return this.belongsTo('Type', 'type_id');
    },
    grandpa() {
        return this.belongsTo('Type', 'grand_id');
    },
    customer() {
        return this.belongsTo('User', 'customer_id');
    }
}, {
    OFFLINE: 0,
    PENDING: 1,
    READY: 2,
    UNUSED: 3,
    USED: 4,
    COMPLETED: 5
});

Ticket.Collection = db.Collection.extend({
    model: Ticket
});
module.exports = Ticket;